home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Classicos / Pac Man white.swf / scripts / frame_4 / DoAction.as
Encoding:
Text File  |  2006-06-13  |  4.9 KB  |  235 lines

  1. function initVars()
  2. {
  3.    pacDir = 3;
  4.    pacPos = 0;
  5.    pacX = 14;
  6.    pacY = 23;
  7.    nextX = pacX - 1;
  8.    nextY = pacY;
  9.    nextPacDir = 3;
  10.    ghKill = 100;
  11.    ghBlue = 0;
  12.    numEyes = 0;
  13.    Pacman.gotoAndStop(1);
  14.    pacStep = 4;
  15.    pacPosMax = 2;
  16.    pauseCount = 0;
  17.    with(Pacman)
  18.    {
  19.       _x = OFFX + 12 * pacX;
  20.       _y = OFFY + 12 * pacY;
  21.       _rotation = 0;
  22.    }
  23.    tellTarget(Ghost[1])
  24.    {
  25.       ghPos = 1;
  26.       ghDir = 3;
  27.       ghX = 13;
  28.       ghY = 11;
  29.       ghNX = ghX - 1;
  30.       _Y = _root.OFFY + 132;
  31.       cOrig = 14483456;
  32.    }
  33.    tellTarget(Ghost[2])
  34.    {
  35.       ghDir = 0;
  36.       ghX = 13;
  37.       cOrig = 16751001;
  38.    }
  39.    tellTarget(Ghost[3])
  40.    {
  41.       ghDir = 2;
  42.       ghX = 11;
  43.       cOrig = 6750207;
  44.    }
  45.    tellTarget(Ghost[4])
  46.    {
  47.       ghDir = 2;
  48.       ghX = 15;
  49.       cOrig = 16750848;
  50.    }
  51.    g = 1;
  52.    while(g < 5)
  53.    {
  54.       tellTarget(Ghost[g])
  55.       {
  56.          if(this.g > 1)
  57.          {
  58.             ghPos = 0;
  59.             ghY = 14;
  60.             ghNX = ghX;
  61.             _Y = _root.OFFY + 174;
  62.          }
  63.          _X = _root.OFFX + 12 * ghX + 6;
  64.          gotoAndStop(1);
  65.          Eyes.gotoAndStop(1);
  66.          gNum = 0;
  67.          ghNY = ghY;
  68.          ghStep = 4;
  69.          ghPosMax = 2;
  70.          ghFast = true;
  71.          Shape._visible = true;
  72.          Shape.Hit._visible = true;
  73.          c = new Color(Shape);
  74.          c.setRGB(cOrig);
  75.       }
  76.       g++;
  77.    }
  78. }
  79. function setPacMove(d)
  80. {
  81.    var _l1 = d;
  82.    if(_l1 == 0)
  83.    {
  84.       nextX = pacX;
  85.       nextY = pacY - 1;
  86.       Pacman._rotation = 90;
  87.    }
  88.    else if(_l1 == 1)
  89.    {
  90.       nextX = pacX + 1;
  91.       nextY = pacY;
  92.       Pacman._rotation = 180;
  93.    }
  94.    else if(_l1 == 2)
  95.    {
  96.       nextX = pacX;
  97.       nextY = pacY + 1;
  98.       Pacman._rotation = -90;
  99.    }
  100.    else if(_l1 == 3)
  101.    {
  102.       nextX = pacX - 1;
  103.       nextY = pacY;
  104.       Pacman._rotation = 0;
  105.    }
  106. }
  107. function setGhMove(d, g)
  108. {
  109.    with(Ghost[g])
  110.    {
  111.       if(d == 0)
  112.       {
  113.          ghNX = ghX;
  114.          ghNY = ghY - 1;
  115.       }
  116.       else if(d == 1)
  117.       {
  118.          ghNX = ghX + 1;
  119.          ghNY = ghY;
  120.       }
  121.       else if(d == 2)
  122.       {
  123.          ghNX = ghX;
  124.          ghNY = ghY + 1;
  125.       }
  126.       else if(d == 3)
  127.       {
  128.          ghNX = ghX - 1;
  129.          ghNY = ghY;
  130.       }
  131.    }
  132. }
  133. function startBGSnd()
  134. {
  135.    var _l1 = _root;
  136.    tellTarget("BGSnd")
  137.    {
  138.       if(_l1.ghBlue > 2)
  139.       {
  140.          if(_l1.numEyes)
  141.          {
  142.             EyesGh.start(0,100);
  143.             BlueGh.stop();
  144.          }
  145.          else
  146.          {
  147.             EyesGh.stop();
  148.             BlueGh.start(0,100);
  149.          }
  150.       }
  151.       else
  152.       {
  153.          BlueGh.stop();
  154.          EyesGh.stop();
  155.          _l1["Back" + _l1.bgNum].start(0,1000);
  156.       }
  157.    }
  158. }
  159. OFFX = 18;
  160. OFFY = 18;
  161. score = 0;
  162. lastScore = 0;
  163. lives = 3;
  164. level = 0;
  165. fruitNum = 1;
  166. notMute = true;
  167. newLev = true;
  168. newGame = true;
  169. newLife = false;
  170. quttting = false;
  171. quit = false;
  172. Snd.ChSnd = true;
  173. Pacman.Hit._visible = false;
  174. ghPause = 40;
  175. ghBVal = 162;
  176. ghMove = new Array(4);
  177. ghChoice = new Array(4);
  178. ghBest = new Array(4);
  179. var g = 1;
  180. while(g < 5)
  181. {
  182.    Ghost.attachMovie("Ghost",g,g);
  183.    Ghost.attachMovie("GhKill","K" + g,g + 4);
  184.    Ghost["K" + g].kval = "";
  185.    g++;
  186. }
  187. var i = 1;
  188. while(i < 5)
  189. {
  190.    _root["Life" + i].gotoAndStop(1);
  191.    if(i >= lives)
  192.    {
  193.       _root["Life" + i]._visible = false;
  194.    }
  195.    i++;
  196. }
  197. m = "#############################............##............##.####.#####.##.#####.####.##O####.#####.##.#####.####O##.####.#####.##.#####.####.##..........................##.####.##.########.##.####.##.####.##.########.##.####.##......##....##....##......#######.##### ## #####.############.##### ## #####.############.##          ##.############.## ######## ##.############.## # # # ## ##.######L     .   # # # ##   .     R######.## ### #### ##.############.## ######## ##.############.##          ##.############.## ######## ##.############.## ######## ##.#######............##............##.####.#####.##.#####.####.##.####.#####.##.#####.####.##O..##.......  .......##..O####.##.##.########.##.##.######.##.##.########.##.##.####......##....##....##......##.##########.##.##########.##.##########.##.##########.##..........................#############################";
  198. var i = -1;
  199. while(i < 29)
  200. {
  201.    Maze.attachMovie("Empty",i,i + 1);
  202.    i++;
  203. }
  204. pos = 0;
  205. var j = 0;
  206. while(j < 31)
  207. {
  208.    var i = 0;
  209.    while(i < 28)
  210.    {
  211.       Maze[i][j] = m.charAt(pos++);
  212.       pill = false;
  213.       if(Maze[i][j] == ".")
  214.       {
  215.          pill = true;
  216.          Maze[i].attachMovie("Pill","P" + j,pos);
  217.       }
  218.       if(Maze[i][j] == "O")
  219.       {
  220.          pill = true;
  221.          Maze[i].attachMovie("Power","P" + j,pos);
  222.       }
  223.       if(pill)
  224.       {
  225.          with(Maze[i]["P" + j])
  226.          {
  227.             _x = OFFX + 12 * i;
  228.             _y = OFFY + 12 * j;
  229.          }
  230.       }
  231.       i++;
  232.    }
  233.    j++;
  234. }
  235.